local xinmashikong_translate = fk.CreateSkill{
    name = "rmt__xinmashikong_translate",
    dynamic_desc = function (self, player, lang)
        local str = ""
        if type(player:getMark("rmt__xinmashikong_translate")) == "table" then
            str = str .. table.concat(player:getMark("rmt__xinmashikong_translate"),"<br>")
        end
        if #player:getCardIds("ej") > 0 then
            local equips = {}
            for _, id in ipairs(player:getCardIds("ej")) do
                local card = Fk:getCardById(id)
                table.insert(equips,card.name)
            end
            if #equips > 0 then
                str = str .. "<br>--------------------<br>"
                str = str .. table.concat(table.map(equips,function (equip)
                    return "<b>"..Fk:translate(equip,"zh_CN").."</b>："..Fk:translate(":"..equip,"zh_CN")
                end),"<br>--------------------<br>")
            end
        end
        for i = 1, 300, 1 do
            str = str .. "<br>"
        end
        return str
    end,
    tags = {Skill.Permanent}
}
Fk:loadTranslationTable{
    ["rmt__xinmashikong_translate"] = "乱码描述",
    [":rmt__xinmashikong_translate"] = "",
}

Fk:addQmlMark{
    name = "xinmashikong",
    how_to_show = function(name, value)
        return " "
    end,
    qml_path = function(name, value, p)
        if Self:isBuddy(p) then
            return "packages/utility/qml/DetailBox"
        end
        return ""
    end,
}

xinmashikong_translate:addEffect("active",{
    mute = true,
    card_num = 1,
    target_num = 1,
    card_filter = function (self, player, to_select, selected, selected_targets)
        return #selected == 0
    end,
    target_filter = function (self, player, to_select, selected, selected_cards, card, extra_data)
        return #selected == 0 and to_select ~= player and to_select:hasSkill("rmt__xinmashikong") and
        not table.contains(player:getTableMark("rmt__xinmashikong_targets-phase"), to_select.id)
    end,
    can_use = function(self, player)
        local targetRecorded = player:getTableMark("rmt__xinmashikong_targets-phase")
        return table.find(Fk:currentRoom().alive_players, function(p)
            return p ~= player and p:hasSkill("rmt__xinmashikong", true) and not table.contains(targetRecorded, p.id)
        end)
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local target = effect.tos[1]
        room:notifySkillInvoked(target,"rmt__xinmashikong","special")
        room:addTableMarkIfNeed(player, "rmt__xinmashikong_targets-phase", target.id)
        local id = effect.cards[1]
        room:obtainCard(target.id, id, false, fk.ReasonGive, player.id)

        local mark = player:getTableMark("@[xinmashikong]rmt__xinmashikong-phase")
        for _, cp in ipairs(room.players) do
            table.insertIfNeed(mark,cp.general)
            for _, skill in ipairs(cp.player_skills) do
                local name = skill.name
                local str = Fk:translate(":"..name,"zh_CN")
                if str and str ~= "" and not skill:isEquipmentSkill(cp) then
                    table.insertIfNeed(mark,name)
                end
            end
            table.insert(mark,"==========")
        end
        room:setPlayerMark(player,"@[xinmashikong]rmt__xinmashikong-phase",mark)
    end,
})

return xinmashikong_translate